package com.lanou.service.SelectArticalService;

import com.lanou.bean.ArticalListBean;
import com.lanou.bean.BlogBean;
import com.lanou.mapper.selectartical.SelectArticalMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/2/26.
 */
@Component
public class SelectArticalServiceImpl implements SelectArticalService {
   @Resource
    SelectArticalMapper selectArticalMapper;

    @Override
    public ArticalListBean selectArticalListbypage(int page, int num) {
        int startpage = (page-1)*num;
        List<BlogBean> blogs = selectArticalMapper.selectArticalListbypage(startpage, startpage + num);
        ArticalListBean articalListBean = new ArticalListBean();
        articalListBean.setStatue("请求成功");
        articalListBean.setBlogs(blogs);
        articalListBean.setNum(num);
        articalListBean.setPage(page);
        articalListBean.setSelectResult(true);
        return articalListBean;
    }

    @Override
    public ArticalListBean selectArticalListbypageandUserId(int page, int num, int userId) {
        int startpage = (page-1)*num;
        List<BlogBean> blogs = selectArticalMapper.selectArticalListbypageandUserId(startpage, startpage + num,userId);
        ArticalListBean articalListBean = new ArticalListBean();
        articalListBean.setStatue("请求成功");
        articalListBean.setBlogs(blogs);
        articalListBean.setNum(num);
        articalListBean.setPage(page);
        articalListBean.setSelectResult(true);
        return articalListBean;
    }
}
